<template>
  <div id="SinceBuildings">
    <div v-show="!showHistory">
      <div class="tab">
        <ul>
          <li v-for="(item, index) in tabArr" :class="{ select: nowIndex === index }" :key="index"
            @click="tabClick(index)">
            <p>{{ item }}</p>
            <span v-if="nowIndex === index"
              style="width: 64px; height: 6px; background: #007aff; border-radius: 3px; display: inline-block">
            </span>
          </li>
        </ul>
      </div>
      <div v-if="nowIndex === 0" class="content" style="height: calc(100vh - 50px)">
        <p style="text-align: center; font-weight: bold; margin-bottom: 10px">房屋检查(监督)表</p>
        <div style="padding-bottom: 10px ">
          <van-field v-for="(item, index) in basicInformation" :key="index" readonly v-model="formData[item.key]"
            :label="item.name" />
        </div>
        <!--<div>-->
        <!--&lt;!&ndash; <van-field readonly v-model="formData.PCR" placeholder="排查人" label="排查人" />-->
        <!--<van-field readonly v-model="formData.PCSJ" placeholder="排查时间" label="排查时间" /> &ndash;&gt;-->
        <!--<van-field readonly v-model="formData.provinceName" label="所属省" />-->
        <!--<van-field readonly v-model="formData.cityByName" label="所属市" />-->
        <!--<van-field readonly v-model="formData.countryName" label="所属区县" />-->
        <!--<van-field readonly v-model="formData.townName" label="所属乡(镇、街道)" />-->
        <!--<van-field readonly v-model="formData.villageName" label="所属村(社区)" />-->
        <!--<van-field required v-model="formData.cqrxm" label="产权人(使用人)姓名" />-->
        <!--<van-field required v-model="formData.cqrzjhm" label="身份证" />-->
        <!--<div></div>-->
        <!--<van-field-->
        <!--:disabled="!isAdd"-->
        <!--required-->
        <!--readonly-->
        <!--clickable-->
        <!--name="picker"-->
        <!--:value="formData.fwyt | inUseName(selectData.FWYTArr)"-->
        <!--label="房屋用途"-->
        <!--@click="isAdd ? (selectData.showPickerFWYT = false) : ''"-->
        <!--/>-->
        <!--<van-popup v-model="selectData.showPickerFWYT" position="bottom" get-container="#popup">-->
        <!--<van-picker-->
        <!--value-key="DICNAME"-->
        <!--show-toolbar-->
        <!--:columns="selectData.FWYTArr"-->
        <!--@confirm="onConfirmFWYT"-->
        <!--@cancel="selectData.showPickerFWYT = false"-->
        <!--/>-->
        <!--</van-popup>-->
        <!--<van-field-->
        <!--:disabled="!isAdd"-->
        <!--required-->
        <!--readonly-->
        <!--clickable-->
        <!--name="picker"-->
        <!--:value="formData.sftszz | inUseName(selectData.columns)"-->
        <!--label="是否同时自住"-->
        <!--@click="isAdd ? (selectData.showPickerFWYT1 = false) : ''"-->
        <!--/>-->
        <!--<van-popup v-model="selectData.showPickerFWYT1" position="bottom" get-container="#popup">-->
        <!--<van-picker-->
        <!--value-key="DICNAME"-->
        <!--show-toolbar-->
        <!--:columns="selectData.columns"-->
        <!--@confirm="onConfirmFWYT1"-->
        <!--@cancel="selectData.showPickerFWYT1 = false"-->
        <!--/>-->
        <!--</van-popup>-->
        <!--<div></div>-->
        <!--<van-field-->
        <!--:disabled="!isAdd"-->
        <!--required-->
        <!--readonly-->
        <!--clickable-->
        <!--name="picker"-->
        <!--:value="formData.jglx | inUseName(selectData.columnsJGLX)"-->
        <!--label="结构类型"-->
        <!--@click="isAdd ? (selectData.showPickerJGLX = false) : ''"-->
        <!--/>-->
        <!--<van-popup v-model="selectData.showPickerJGLX" position="bottom" get-container="#popup">-->
        <!--<van-picker-->
        <!--value-key="DICNAME"-->
        <!--show-toolbar-->
        <!--:columns="selectData.columnsJGLX"-->
        <!--@confirm="onConfirmJGLX"-->
        <!--@cancel="selectData.showPickerJGLX = false"-->
        <!--/>-->
        <!--</van-popup>-->
        <!--<van-field-->
        <!--:disabled="!isAdd"-->
        <!--required-->
        <!--readonly-->
        <!--clickable-->
        <!--name="picker"-->
        <!--:value="formData.jtjglx | inUseName(selectData.columnsJTJG)"-->
        <!--label="具体结构"-->
        <!--@click="isAdd ? (selectData.showPickerJTJG = false) : ''"-->
        <!--/>-->
        <!--<van-popup v-model="selectData.showPickerJTJG" position="bottom" get-container="#popup">-->
        <!--<van-picker-->
        <!--value-key="DICNAME"-->
        <!--show-toolbar-->
        <!--:columns="selectData.columnsJTJG"-->
        <!--@confirm="onConfirmJTJG"-->
        <!--@cancel="selectData.showPickerJTJG = false"-->
        <!--/>-->
        <!--</van-popup>-->
        <!--<van-field-->
        <!--:disabled="!isAdd"-->
        <!--required-->
        <!--readonly-->
        <!--clickable-->
        <!--name="picker"-->
        <!--:value="formData.sfgkj | inUseName(selectData.columns)"-->
        <!--label="是否改扩建"-->
        <!--@click="isAdd ? (selectData.showPickersfgkj = false) : ''"-->
        <!--/>-->
        <!--<van-popup v-model="selectData.showPickersfgkj" position="bottom" get-container="#popup">-->
        <!--<van-picker-->
        <!--value-key="DICNAME"-->
        <!--show-toolbar-->
        <!--:columns="selectData.columns"-->
        <!--@confirm="onConfirmsfgkj"-->
        <!--@cancel="selectData.showPickersfgkj = false"-->
        <!--/>-->
        <!--</van-popup>-->
        <!--<div></div>-->
        <!--<van-field-->
        <!--:disabled="!isAdd"-->
        <!--required-->
        <!--readonly-->
        <!--clickable-->
        <!--name="picker"-->
        <!--:value="formData.aqyhcp | inUseName(selectData.columnsaqyhcp)"-->
        <!--label="初步判定"-->
        <!--@click="isAdd ? (selectData.showPickeraqyhcp = false) : ''"-->
        <!--/>-->
        <!--<van-popup v-model="selectData.showPickeraqyhcp" position="bottom" get-container="#popup">-->
        <!--<van-picker-->
        <!--value-key="DICNAME"-->
        <!--show-toolbar-->
        <!--:columns="selectData.columnsaqyhcp"-->
        <!--@confirm="onConfirmaqyhcp"-->
        <!--@cancel="selectData.showPickeraqyhcp = false"-->
        <!--/>-->
        <!--</van-popup>-->
        <!--<van-field-->
        <!--:disabled="!isAdd"-->
        <!--required-->
        <!--readonly-->
        <!--clickable-->
        <!--name="picker"-->
        <!--:value="formData.sfaqjd | inUseName(selectData.columns)"-->
        <!--label="是否安全鉴定"-->
        <!--@click="isAdd ? (selectData.showPickersfaqjd = false) : ''"-->
        <!--/>-->
        <!--<van-popup v-model="selectData.showPickersfaqjd" position="bottom" get-container="#popup">-->
        <!--<van-picker-->
        <!--value-key="DICNAME"-->
        <!--show-toolbar-->
        <!--:columns="selectData.columns"-->
        <!--@confirm="onConfirmsfaqjd"-->
        <!--@cancel="selectData.showPickersfaqjd = false"-->
        <!--/>-->
        <!--</van-popup>-->
        <!--<van-field-->
        <!--:disabled="!isAdd"-->
        <!--required-->
        <!--readonly-->
        <!--clickable-->
        <!--name="picker"-->
        <!--:value="formData.jdjl | inUseName(selectData.columnsjdjl)"-->
        <!--label="鉴定结论"-->
        <!--@click="isAdd ? (selectData.showPickerjdjl = false) : ''"-->
        <!--/>-->
        <!--<van-popup v-model="selectData.showPickerjdjl" position="bottom" get-container="#popup">-->
        <!--<van-picker-->
        <!--value-key="DICNAME"-->
        <!--show-toolbar-->
        <!--:columns="selectData.columnsjdjl"-->
        <!--@confirm="onConfirmjdjl"-->
        <!--@cancel="selectData.showPickerjdjl = false"-->
        <!--/>-->
        <!--</van-popup>-->
        <!--<van-field-->
        <!--:disabled="!isAdd"-->
        <!--required-->
        <!--readonly-->
        <!--clickable-->
        <!--name="picker"-->
        <!--:value="formData.JGLX | inUseName(selectData.columnsJGLX)"-->
        <!--label="管理措施"-->
        <!--@click="isAdd ? (selectData.showPickerJGLX = false) : ''"-->
        <!--/>-->
        <!--<van-popup v-model="selectData.showPickerJGLX" position="bottom" get-container="#popup">-->
        <!--<van-picker-->
        <!--value-key="DICNAME"-->
        <!--show-toolbar-->
        <!--:columns="selectData.columnsJGLX"-->
        <!--@confirm="onConfirmJGLX"-->
        <!--@cancel="selectData.showPickerJGLX = false"-->
        <!--/>-->
        <!--</van-popup>-->
        <!--<van-field-->
        <!--:disabled="!isAdd"-->
        <!--required-->
        <!--readonly-->
        <!--clickable-->
        <!--name="picker"-->
        <!--:value="formData.JGLX | inUseName(selectData.columnsJGLX)"-->
        <!--label="工程措施"-->
        <!--@click="isAdd ? (selectData.showPickerJGLX = false) : ''"-->
        <!--/>-->
        <!--<van-popup v-model="selectData.showPickerJGLX" position="bottom" get-container="#popup">-->
        <!--<van-picker-->
        <!--value-key="DICNAME"-->
        <!--show-toolbar-->
        <!--:columns="selectData.columnsJGLX"-->
        <!--@confirm="onConfirmJGLX"-->
        <!--@cancel="selectData.showPickerJGLX = false"-->
        <!--/>-->
        <!--</van-popup>-->
        <!--<div></div>-->
        <!--</div>-->
      </div>
      <div v-if="nowIndex === 1" class="content">
        <p style="text-align: center; font-weight: bold; margin-bottom: 10px">房屋检查(监督)表</p>
        <!--<div style="position: fixed;width: 100vw;height: 100vh;display: flex;align-items: center;justify-content: center;">-->
        <!--<van-loading size="24px" vertical>加载中...</van-loading>-->
        <!--</div>-->
        <div class="list">
          <ul>
            <li v-for="(item, index) in contentData" :key="index + 'contentData'" :style="{
              borderBottom: index === contentData.length - 1 ? 'none' : '1px solid #D2D2D2',
            }">
              <span style="color: red" v-if="!item.fileData">*</span>
              <span style="color: #007aff">{{ item.name }}</span>
              <div size="mini">
                <div class="btn-style" v-for="(item1, index1) in item.children" :key="index1 + 'children'" :style="{
                  borderBottom: item.children.length - 1 === index1 ? 'none' : '',
                }" :label="item1.name">
                  <span v-if="item1.type == 'select'" style="padding-top: 10px">
                    <van-field style="padding: 10px 0" readonly :required="item1.required" clickable name="picker"
                      :value="houseCheckInfo[item1.key] | inUseName(item1.ARR)" :label="item1.name"
                      @click="item1.name !== '安全隐患初判' ? (isAdd ? (item1.active = true) : '') : ''" />
                    <van-popup v-model="item1.active" position="bottom" get-container="#popup">
                      <van-picker :required="item1.required" value-key="DICNAME" show-toolbar :columns="item1.ARR"
                        @confirm="onConfirmContent" @cancel="item1.active = false" />
                    </van-popup>
                  </span>
                  <span v-else-if="item1.type == 'text'" style="font-size: 14px"> </span>

                  <span v-else-if="item1.type == 'Checkbox'">
                    <p v-if="item.name == '检查(督察)结论'" style="font-size: 14px">
                      与房屋建筑和市政设施调查系统符合情况
                    </p>
                    <!--<p v-if="item.name=='抽查结果'" style="font-size: 14px">与房屋建筑和市政设施调查系统符合情况：</p>-->
                    <van-radio-group v-model="houseCheckInfo[item1.key]" direction="horizontal" :disabled="!isAdd">
                      <van-radio style="margin-bottom: 5px; font-size: 14px" v-for="(item2, index2) in item1.children"
                        :key="index2 + 'childrens'" :name="item2.value"><span style="font-size: 14px">{{ item2.name
                        }}</span>
                      </van-radio>
                    </van-radio-group>
                    <p v-if="item.name == '基本信息是否准确'">
                      <van-field v-model="houseCheckInfo.jcCheckInfoInput" placeholder="请输入内容" />
                    </p>
                    <p v-if="item.title && houseCheckInfo.checkFirstResult == 1">
                      {{ item.titleName }}
                    </p>
                  </span>
                  <span v-else>
                    <van-checkbox-group v-model="houseCheckInfo[item.key]"  >
                      <van-checkbox style="margin-bottom: 10px" shape="square" :name="item1.value"  @click="mutualClick(item1, item)">
                        <span style="font-size: 14px"> {{ item1.name }}</span>
                      </van-checkbox>
                    </van-checkbox-group>
                    <span style="float: right; padding-top: 10px"> </span>
                    <span v-for="(item3, index3) in item1.fileData" :key="index3 + 'fileData3'">
                      <van-uploader :disabled="!isAdd" @click-upload="getList(item3)" :after-read="afterRead"
                        :before-delete="delectFile" v-model="item3.fileList" accept=".jpg,.gif,.png,.jpeg" multiple />
                    </span>
                  </span>
                </div>
                <!--<div v-if="item.name == '统一社会信用代码'">-->
                <!--<van-cell-group v-show="formData.fwyt != '2'">-->
                <!--<van-field v-model="houseCheckInfo.jcTyshxydm" label="" placeholder="请输入统一社会信用代码">-->
                <!--<template #button>-->
                <!--&lt;!&ndash;v-if="isTrue1"&ndash;&gt;-->
                <!--<van-button  size="small" type="primary" @click="handleYanZheng">验证</van-button>-->
                <!--&lt;!&ndash;<van-icon v-if="isTrue && !isTrue1" name="success" @click="handleYanZheng1" color="green" />&ndash;&gt;-->
                <!--&lt;!&ndash;<van-icon v-if="!isTrue && !isTrue1" name="cross" @click="handleYanZheng1" color="red" />&ndash;&gt;-->
                <!--</template>-->
                <!--</van-field>-->
                <!--</van-cell-group>-->
                <!--</div>-->
                <div v-if="item.name == '初步判定' && houseCheckInfo.checkFirstResult == 2">
                  <!--<p class="subTitle"><span class="line"></span>鉴定整治方式</p>-->
                  <span style="color: red">*</span>
                  <span style="color: #007aff">鉴定整治方式</span>
                  <!--:readonly="disabled"-->
                  <van-form ref="ruleFormZZFS" validate-firstm scroll-to-error>
                    <van-field required name="picker" :value="JBXXform.appraiseFirst | inUseName2(Enum.JDJG)" label="鉴定机构"
                      placeholder="请选择" @click="Enum.ISJDJG = true" clickable readonly :rules="ruleBlur" />
                    <van-popup v-model="Enum.ISJDJG" position="bottom">
                      <van-picker value-key="name" title="鉴定机构" show-toolbar :columns="Enum.JDJG" @confirm="onConfirmJDJG"
                        @cancel="Enum.ISJDJG = false" />
                    </van-popup>
                    <template v-if="JBXXform.appraiseFirst == 0">
                      <van-field required name="picker" v-if="JBXXform.appraiseFirst == 0" :value="JBXXform.usccName"
                        label="鉴定机构名称" placeholder="请选择" @click="Enum.ISJDDJ = true" clickable readonly
                        :rules="ruleBlur" />
                      <van-popup v-model="Enum.ISJDDJ" position="bottom">
                        <van-picker value-key="qymc" title="鉴定机构名称" show-toolbar :columns="Enum.JDDJ"
                          @confirm="onConfirmJDDJ" @cancel="Enum.ISJDDJ = false" />
                      </van-popup>
                      <van-field v-model="JBXXform.uscc" label="统一社会信用代码" readonly />
                    </template>
                    <van-field required name="picker" :value="JBXXform.removeDangerMode" label="整治方式" placeholder="请选择"
                      @click="disabled ? '' : Enum.ISZZFS = true" clickable readonly :rules="ruleBlur" />
                    <van-popup v-model="Enum.ISZZFS" position="bottom">
                      <van-picker title="整治方式" show-toolbar
                        :columns="['腾空防控', '监控使用', '维修加固', '拆除重建', '拆除灭失', '拆除安置', '置换安置', '租用安置']"
                        @confirm="(val) => { JBXXform.removeDangerMode = val; Enum.ISZZFS = false }"
                        @cancel="Enum.ISZZFS = false" />
                    </van-popup>
                  </van-form>
                  <div v-for="( itemUrl, index ) in  fileList" :key="index">
                    <div style="padding:10px" @click="getGroupGuids(itemUrl, fileList)">
                      <div style="font-size: 14px;margin-bottom: 10px;">
                        <span style="color:red" v-if="itemUrl.isHas">*</span>
                        {{ itemUrl.name }}
                      </div>
                      <van-uploader :disabled="disabled" :after-read="afterRead2" :before-delete="delectFile2"
                        v-model="itemUrl.fileList" accept=".jpg,.gif,.png,.jpeg" />
                    </div>
                  </div>
                </div>
                <div v-if="item.name == '其它问题'">
                  <van-cell-group>
                    <van-field v-model="houseCheckInfo.jcOther" label="" placeholder="请输入内容" />
                  </van-cell-group>
                </div>
                <div v-for="(item2, index2) in item.fileData" :key="index2 + 'fileData'">
                  <p style="font-size: 14px">
                    {{ item2.name }}
                  </p>
                  <van-uploader v-model="item2.fileList" :after-read="afterRead" :before-delete="delectFile"
                    accept="image/jpeg, image/png, image/jpg, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, application/pdf">
                    <!-- <van-image v-show="fileUrl.length>0" v-for="(item,index) in fileUrl" :key="index"  width="60" height="60"
                             :src="item.url" /> -->
                    <!--<template default>-->
                    <!--<img v-if="item2.fileList.length == 0" width="180" src="https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/ZLJ/sfz1011.png" alt="">-->
                    <!--<img v-else-->
                    <!--v-for="(item,index) in item2.fileList" :key="index"-->
                    <!--:src="-->
                    <!--item2.fileList.length>0-->
                    <!--? item.url-->
                    <!--: ''-->
                    <!--"-->
                    <!--width="200"-->
                    <!--alt=""-->
                    <!--/>-->
                    <!--</template>-->
                  </van-uploader>
                </div>
              </div>
            </li>
          </ul>
        </div>
      </div>
      <div class="footer" v-if="nowIndex === 1 && !ISShow">
        <span v-if="$route.query.index == 0 && !showHistoryBtn">
          <van-button size="small" type="info" @click="saveUpdates(true)">保存</van-button>
          <van-button size="small" type="info" @click="submitData">提交</van-button>
        </span>
        <van-button v-if="!showHistoryBtn" size="small" type="info" @click="HistoryCheck">历史检查记录</van-button>
        <van-button v-if="showHistoryBtn" size="small" type="info" @click="cityList = [], getHistory()">返回</van-button>
      </div>
    </div>
    <div v-if="showHistory" style="">
      <div class="middle" style="overflow: auto;">
        <div class="search-list">
          <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
            <div class="search-list-top" v-for="(item, index) in cityList" :key="index" @click="SelectGoto(item)">
              <div class="top1">
                <div style="font-size:18px;float: left; font-weight:1000; color: #000;line-height: 36px;">
                  <span style="font-weight: bold;">户主名称：{{ item.cqr }}</span>
                </div>

              </div>
              <div class="top1" style="font-size:18px;clear:both;color: #000;line-height: 36px;">
                <span style="font-weight: bold;">核查结论：{{ item.checkFirstResultName }}</span>
              </div>
              <div class="top">
                <div style="float: left;font-size:14px;">
                  <span>自建房排查编号：{{ item.yhfwbh }}</span>
                </div>

              </div>
              <div class="top">
                <div style="float: right;font-size:14px;">
                  <span>房屋用途：{{ item.fwyt }}</span>
                </div>
              </div>
              <div class="top">
                <div style="float: left;font-size:14px;">
                  <span>检查人：{{ item.checkUser }}</span>
                </div>
              </div>
              <div class="top">
                <div style="float: left;font-size:14px;">
                  <span>检查时间：{{ item.checkTime }}</span>
                </div>
              </div>
              <div class="top">
                <div style="float: left;font-size:14px;">
                  <span>地址：{{ item.address }}</span>
                </div>
              </div>
            </div>
          </van-list>
          <div style="position:absolute;bottom:10px;">
            <div style="display: flex;justify-content: center;align-items: center;width: 100vw;">
              <van-button size="small" type="info" @click="goback">返回</van-button>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {
  FileServerProxy,
  houseCheckFwCheckCountrySave,
  getPoliceData,
  ossUploadFiles,
  FwsaveOrDeleteFwCheck,
  houseCheckFwCheckCountryGet,
  ossdelteFiles,
  queryList
} from '@/utils/api'
import { isArray } from 'lodash'
import { Dialog } from 'vant'
import axios from 'axios'
import dd from 'gdt-jsapi'

export default {
  name: 'SinceBuildings',
  filters: {
    inUseName: function (msg, data) {
      let name = ''
      if (data != undefined) {
        data.forEach((item) => {
          if (item.DICID == msg) {
            name = item.DICNAME
          }
        })
        return name
      }
    },
    inUseName2: function (msg, data) {
      let name = ''
      data.forEach((item) => {
        if (item.value == msg) {
          name = item.name
        }
      })
      return name
    },
  },
  data() {
    return {
      disabled: false,
      photoData: [],
      fileList: [
        // {
        //   name: '安全隐患通知书照片',
        //   groupGuid: '',
        //   isHas: false,
        //   fileList: [],
        //   type: 'img'
        // },
        {
          name: '房屋照片',
          groupGuid: '',
          isHas: true, //是否必传
          fileList: [],
          type: 'img'
        },
      ],
      ruleBlur: [{ required: true, message: ' ', trigger: "blur" }],
      JBXXform: {
        appraiseFirst: 0,
        removeDangerMode: "",
        usccName: "",
        uscc: "",
        houseGroupId:"",
        checkUserId:''
      },
      Enum: {
        ISJDJG: false,
        JDJG: [{
          name: '无需鉴定',
          value: 1
        }, {
          name: '需要鉴定',
          value: 0
        }],
        ISFWYT: false,
        FWYT: [{
          name: '经营性自建房',
          value: 1
        }, {
          name: '其他自建房',
          value: 2
        }],
        ISJTYT: false,
        JTYT: [{
          name: '餐饮饭店',
          value: '1'
        },
        {
          name: '民宿宾馆',
          value: '2'
        },
        {
          name: '批发零售',
          value: '3'
        },
        {
          name: '医疗卫生',
          value: '4'
        },
        {
          name: '养老服务',
          value: '5'
        },
        {
          name: '生产加工',
          value: '6'
        },
        {
          name: '仓储物流',
          value: '7'
        },
        {
          name: '出租居住',
          value: '8'
        },
        {
          name: '休闲娱乐',
          value: '9'
        },
        {
          name: '教育培训',
          value: '10'
        },
        {
          name: '商务办公',
          value: '11'
        },
        {
          name: '农贸市场',
          value: '12'
        },
        {
          name: '宗教场所',
          value: '13'
        },
        {
          name: '其他',
          value: '99'
        }],
        ISJGLX: false,
        JGLX: [{
          name: '砌体结构',
          value: '1'
        },
        {
          name: '底部框架-上部砌体结构',
          value: '2'
        },
        {
          name: '钢筋混凝土结构',
          value: '3'
        },
        {
          name: '钢结构',
          value: '4'
        },
        {
          name: '木 (竹) 结构',
          value: '5'
        },
        {
          name: '窑洞',
          value: '6'
        },
        {
          name: '混杂结构',
          value: '7'
        },
        {
          name: '土木/石木结构',
          value: '8'
        },
        {
          name: '其他',
          value: '99'
        }
        ],
        JZND: [{
          name: '1980年及以前',
          value: 1
        }, {
          name: '1981-1990年',
          value: 2
        }, {
          name: '1991-2000年',
          value: 3
        }, {
          name: '2001-2010年',
          value: 4
        }, {
          name: '2011-2015年',
          value: 5
        }, {
          name: '2016年及以后',
          value: 6
        }],
        ISJDDJ: false,
        JDDJ: [],
        ISZZFS: false,
        ISARR: [{
          name: '是',
          value: 1
        }, {
          name: '否',
          value: 0
        }],
        IS: false,
        ISARRF: [{
          name: '是',
          value: 0
        }, {
          name: '否',
          value: 1
        }],
        ISF: false,
      },
      basicInformation: [
        {
          "key": "yhfwbh",
          "name": "自建房安全排查编号",
          "value": ""
        },
        {
          "key": "fwbh",
          "name": "普查房屋编号",
          "value": ""
        },
        {
          "key": "belongCity",
          "name": "所属市"
        },
        {
          "key": "belongCountry",
          "name": "所属区县"
        },
        {
          "key": "address",
          "name": "房屋地址",
          "active": false,
          "width": "100%",
          "value": ""
        },
        {
          "key": "cqr",
          "name": "产权人(使用人)姓名",
          "value": "",
          "active": false,
        },
        {
          "key": "sfzh",
          "name": "身份证号",
          "value": "",
          "active": false,
        },
        {
          "key": "fwyt",
          "name": "房屋用途",
          "value": "",
          "enum": "FWYT",
          "active": false,
        },
        {
          "key": "subFwyt",
          "name": "是否同时居住",
          "value": "",
          "enum": "IS",
          "active": false,
        },
        {
          "key": "jzgn",
          "name": "具体用途",
          "enum": "JTYT",
          "value": "",
          "active": false,
        },
        {
          "key": "tdxz",
          "name": "土地性质",
          "enum": "TDXZ",
          "value": "",
          "active": false,
        },
        {
          "key": "szqy",
          "name": "所在区域",
          "enum": "SZQY",
          "value": "",
          "active": false,
        },
        {
          "key": "rymjcslx",
          "name": "人员密集场所周边",
          "enum": "RYMJCS",
          "value": "",
          "active": false,
        },
        {
          "key": "belongTown",
          "name": "所属乡镇",
          "active": false,
        },
        {
          "key": "belongVillage",
          "name": "所属村",
          "active": false,
        },
        {
          "key": "cs",
          "name": "建筑层数",
          "unit": "层",
          "value": "",
          "active": false,
        },
        {
          "key": "dcmj",
          "name": "建筑面积",
          "unit": "m²",
          "value": "",
          "active": false,
        },
        {
          "key": "jznd",
          "name": "建造年代",
          "value": "",
          "enum": "JZND",
          "active": false,
        },
        {
          "key": "buildTime",
          "name": "具体年份",
          "unit": "年",
          "value": "",
          "active": false,
        },
        {
          "key": "renovateFlag",
          "name": "是否拆除",
          "value": "",
          "active": false,
        },
      ],
      loading: false,
      finished: false,
      cityList: [],
      BaseURL: window.g.BaseURL,
      showHistory: false,
      ishz: false,
      isyezz: false,
      saveStatus: false,
      ISShow: true,
      isTrue: false,
      isTrue1: true,
      UploadFileId: [],
      fileUrl: [],
      cityName: '',
      showData: false,
      isAdd: true,
      contentData: [
        {
          name: '房屋类型',
          children: [
            {
              type: 'Checkbox',
              key: 'fwlx',
              children: [
                {
                  name: '城镇房屋',
                  value: 1,
                  key: 'house_is_error',
                },
                {
                  name: '农村房屋(行政村范围)',
                  value: 2,
                  key: 'house_is_transform',
                },
              ],
              disabled: false,
            },
          ],
        },
        {
          name: '周边情况',
          key: 'buildEnums',
          children: [
            {
              name: '无异常',
              key: 'buildIsError',
              value: '1',
            },
            {
              name: '房屋上装有大型广告牌',
              key: 'buildIsWater',
              value: '2',
            },
            // {
            //   name: '房屋上装有大型广告牌',
            //   key: 'buildIsBillboard',
            //   value: '2',
            // },
            {
              name: '房屋周边有工程建设和深基坑施工情况',
              key: 'buildIsRoadwork',
              value: '3',
            },
            {
              name: '房屋周边有影响安全的危险因素(例如山体滑坡是否稳定、有没有危岩、落石等)',
              key: 'buildIsDanger',
              value: '4',
            },
            {
              name: '是否河道建房',
              key: 'buildIsDanger',
              value: '5',
            },
            // {
            //   name: '是否有未经设计擅自加层的情况',
            //   key: 'buildIsAddfloor',
            //   value: ''
            // },
            {
              name: '有破墙开门、开窗或开店等影响结构安全的行为，或其他改变使用功能有较大变动情况',
              key: 'buildIsStructure',
              value: '6',
            },
          ],
        },
        {
          name: '地基基础',
          key: 'baseEnums',
          children: [
            {
              name: '无异常',
              key: 'baseIsError',
              value: '1',
            },
            {
              name: '房屋出现明显不均匀沉降（斜向）裂缝',
              key: 'baseIsCrack',
              value: '2',
            },
            {
              name: '外露基础明显腐蚀、酥碱、松散 和剥落',
              key: 'baseIsAge',
              value: '3',
            },
            {
              name: '房屋周边地面长期积水',
              key: 'baseIsAge',
              value: '4',
            },
            {
              name: '基础局部或整体塌陷',
              key: 'baseIsSubside',
              value: '5',
            },
          ],
        },
        {
          name: '墙体',
          key: 'liveBrickEnums',
          children: [
            {
              name: '无异常',
              key: 'buildIsError',
              value: '1',
            },
            {
              name: '墙体普遍开裂、变形、歪斜',
              key: 'buildIsError',
              value: '2',
            },
            {
              name: '使用小型混凝土空心砌块',
              key: 'buildIsWater',
              value: '3',
            },
            {
              name: '墙体砌筑不结实',
              key: 'buildIsBillboard',
              value: '4',
            },
            {
              name: '半砖墙作为承重墙',
              key: 'buildIsBillboard',
              value: '5',
            },
          ],
        },
        {
          name: '承重木架构',
          key: 'liveWoodEnums',
          children: [
            {
              name: '无异常',
              key: 'buildIsError',
              value: '1',
            },
            {
              name: '明显腐朽或虫蛀',
              key: 'buildIsWater',
              value: '2',
            },
            {
              name: '木构架明显变形或出现横向裂缝',
              key: 'buildIsBillboard',
              value: '3',
            },
            {
              name: '柱身明显歪斜、错位',
              key: 'buildIsBillboard',
              value: '4',
            },
          ],
        },
        {
          name: '混凝土构件',
          key: 'liveBetonEnums',
          children: [
            {
              name: '无异常',
              key: 'buildIsError',
              value: '1',
            },
            {
              name: '保护层剥落严重',
              key: 'buildIsWater',
              value: '2',
            },
            {
              name: '钢筋露筋、锈蚀',
              key: 'buildIsBillboard',
              value: '3',
            },
            {
              name: '梁柱出现明显受力裂缝和变形',
              key: 'buildIsRoadwork',
              value: '4',
            },
            {
              name: '预制板有坠落危险',
              key: 'buildIsRoadwork',
              value: '5',
            },
          ],
        },
        {
          name: '屋面',
          key: 'houseEnums',
          children: [
            {
              name: '无异常',
              key: 'buildIsError',
              value: '1',
            },
            {
              name: '明显变形、裂缝',
              key: 'buildIsWater',
              value: '2',
            },
            {
              name: '较大范围渗漏',
              key: 'buildIsBillboard',
              value: '3',
            },
          ],
        },
        {
          name: '使用安全',
          key: 'useSafeEnums',
          children: [
            {
              name: '无异常',
              key: 'buildIsError',
              value: '1',
            },
            {
              name: '楼面、架空屋有不合理堆放重物',
              key: 'buildIsWater',
              value: '2',
            },
            {
              name: '老旧房屋或加建结构、预制板人员聚集',
              key: 'buildIsBillboard',
              value: '3',
            },
          ],
        },
        {
          name: '初步判定',
          title: true,
          titleName: '当前房屋无以上情况且处于正常使用情况下或已鉴定为A、B级。',
          children: [
            {
              type: 'Checkbox',
              key: 'checkFirstResult',
              children: [
                {
                  name: '基本安全',
                  value: 1,
                  key: '',
                },
                {
                  name: '存在风险',
                  value: 2,
                  key: '',
                },
                {
                  name: '危房正在整治中',
                  value: 3,
                  key: '',
                },
                {
                  name: '已拆除',
                  value: 4,
                  key: '',
                },
              ],
              disabled: true,
            },
          ],
        },
        {
          name: '基本信息是否准确',
          children: [
            {
              type: 'Checkbox',
              key: 'jcCheckInfo',
              children: [
                {
                  name: '是',
                  value: 1,
                  key: 'house_is_error',
                },
                {
                  name: '否',
                  value: 2,
                  key: 'house_is_transform',
                },
              ],
              disabled: false,
            },
          ],
        },
        {
          name: '房屋安全鉴定机构是否符合资质要求',
          children: [
            {
              type: 'Checkbox',
              key: 'jcJdjgFhyq',
              children: [
                {
                  name: '符合',
                  value: 1,
                  key: 'house_is_error',
                },
                {
                  name: '不符合',
                  value: 2,
                  key: 'house_is_transform',
                },
              ],
              disabled: false,
            },
          ],
        },
        {
          name: '房屋安全鉴定情况',
          children: [
            {
              type: 'Checkbox',
              key: 'jcIsJd',
              children: [
                {
                  name: '已鉴定',
                  value: 1,
                  key: 'house_is_error',
                },
                {
                  name: '未鉴定',
                  value: 2,
                  key: 'house_is_transform',
                },
              ],
              disabled: false,
            },
          ],
        },
        {
          name: '房屋鉴定报告是否符合要求',
          children: [
            {
              type: 'Checkbox',
              key: 'jcIsJdbg',
              children: [
                {
                  name: '是',
                  value: 1,
                  key: 'house_is_error',
                },
                {
                  name: '否',
                  value: 2,
                  key: 'house_is_transform',
                },
              ],
              disabled: false,
            },
          ],
        },
        // {
        //     name: '房屋照片是否与现场一致',
        //     children: [
        //         {
        //             type: 'Checkbox',
        //             key: 'jcIsZpxc',
        //             children: [
        //                 {
        //                     name: '一致',
        //                     value: 1,
        //                     key: 'house_is_error',
        //                 },
        //                 {
        //                     name: '不一致',
        //                     value: 2,
        //                     key: 'house_is_transform',
        //                 },
        //             ],
        //             disabled: false,
        //         },
        //     ],
        // },
        {
          name: '危房管控措施是否到位',
          children: [
            {
              type: 'Checkbox',
              key: 'jcWfgk',
              children: [
                {
                  name: '是',
                  value: 1,
                  key: 'house_is_error',
                },
                {
                  name: '否',
                  value: 2,
                  key: 'house_is_transform',
                },
              ],
              disabled: false,
            },
          ],
        },
        {
          name: '危房工程整治措施是否到位',
          children: [
            {
              type: 'Checkbox',
              key: 'jcWfgc',
              children: [
                {
                  name: '是',
                  value: 1,
                  key: 'house_is_error',
                },
                {
                  name: '否',
                  value: 2,
                  key: 'house_is_transform',
                },
              ],
              disabled: false,
            },
          ],
        },
        {
          name: '危房使用情况',
          children: [
            {
              type: 'Checkbox',
              key: 'jcHouseUse',
              children: [
                {
                  name: '存在住人现场',
                  value: 1,
                  key: 'house_is_error',
                },
                {
                  name: '存在使用现象',
                  value: 2,
                  key: 'house_is_transform',
                },
              ],
              disabled: false,
            },
          ],
        },
        // {
        //   name: '统一社会信用代码',
        // },
        {
          name: '其它问题',
        },
        {
          fileData: [
            {
              name: '上传照片',
              groupGuid: '3',
              fileList: [],
            },
          ],
        },
      ],
      nowIndex: 0,
      tabArr: ['基本情况', '现场状况'],
      selectData: {
        showPickerq: false,
        showPickerFWYT1: false,
        showPickersfgkj: false,
        currentDate: new Date(),
        showPicker: false,
        columns: [
          {
            DICNAME: '是',
            DICID: 1,
          },
          {
            DICNAME: '否',
            DICID: 2,
          },
        ],
        showPickerFWLX: false,
        FWLXArr: [
          {
            DICNAME: '自建房',
            DICID: '1',
          },
          {
            DICNAME: '非自建房',
            DICID: '2',
          },
        ],
        showPickerFWYT: false,
        FWYTArr: [
          {
            DICNAME: '经营性自建房',
            DICID: 1,
          },
          {
            DICNAME: '其他自建房',
            DICID: 2,
          },
        ],
        showPickerIFTSZZ: false,
        showPickerJGLX: false,
        columnsJGLX: [
          {
            DICNAME: '砌体结构',
            DICID: 1,
          },
          {
            DICNAME: '底部框架-上部砌体结构',
            DICID: 2,
          },
          {
            DICNAME: '钢筋混凝土结构',
            DICID: 3,
          },
          {
            DICNAME: '钢结构',
            DICID: 4,
          },
          {
            DICNAME: '木(竹)结构',
            DICID: 5,
          },
          {
            DICNAME: '土木/石木结构',
            DICID: 6,
          },
          {
            DICNAME: '混杂结构',
            DICID: 7,
          },
          {
            DICNAME: '窑洞',
            DICID: 8,
          },
          {
            DICNAME: '其他',
            DICID: 9,
          },
        ],
        showPickerGKJ: false,
        showPickerJTJG: false,
        columnsJTJG: [
          {
            DICNAME: '预制板',
            DICID: '1',
          },
          {
            DICNAME: '现浇板',
            DICID: '2',
          },
          {
            DICNAME: '木或轻钢楼层盖',
            DICID: '3',
          },
          {
            DICNAME: '石板或石条',
            DICID: '4',
          },
        ],
        showPickerjdjl: false,
        columnsjdjl: [
          {
            DICNAME: 'A级',
            DICID: 1,
          },
          {
            DICNAME: 'B级',
            DICID: 2,
          },
          {
            DICNAME: 'C级',
            DICID: 3,
          },
          {
            DICNAME: 'D级',
            DICID: 4,
          },
        ],
        showPickersfaqjd: false,
        showPickeraqyhcp: false,
        columnsaqyhcp: [
          {
            DICNAME: '安全',
            DICID: 1,
          },
          {
            DICNAME: '基本安全',
            DICID: 2,
          },
          {
            DICNAME: '不安全',
            DICID: 3,
          },
        ],
      },
      showjtfwyt: false,
      //2
      //多选框
      CheckS: {
        baseEnums: [],
        buildEnums: [],
        houseEnums: [],
        liveBetonEnums: [],
        liveBrickEnums: [],
        liveWoodEnums: [],
        useSafeEnums: [],
      },
      houseCheckInfo: {
        baseEnums: [],
        buildEnums: [],
        checkFirstResult: 1,
        checkTime: '',
        checkUser: '',
        fwid: '',
        fwlx: 0,
        houseEnums: [],
        isCheck: 0,
        jcCheckInfo: 0,
        jcCheckInfoInput: '',
        jcHouseUse: 0,
        // jcIsFirstRestut: 0,
        jcIsJd: 0,
        jcIsJdbg: 0,
        // jcIsZpxc: 0,
        jcJdjgFhyq: 0,
        jcOther: '',
        // jcTyshxydm: '',
        jcWfgc: 0,
        jcWfgk: 0,
        liveBetonEnums: [],
        liveBrickEnums: [],
        liveWoodEnums: [],
        pictures: [],
        useSafeEnums: [],
      },
      //1
      formData: {
        cityByCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
        cityByName: '杭州市',
        citycode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
        countryCode: '',
        countryName: '',
        cqrxm: '',
        cqrzjhm: '',
        fwid: '',
        fwpcqk: '',
        fwtybh: '',
        fwyt: 0,
        gkjlx: '',
        gkjnr: '',
        isDelete: 0,
        jcFwJl: '',
        jcJglxJl: '',
        jglx: 0,
        jtjglx: '',
        jtjglxnr: '',
        provinceCode: '330000000000',
        provinceName: '惠州市',
        sfgkj: 0,
        sftszz: 0,
        sjlx: 0,
        townCode: '',
        townName: '',
        villageCode: '',
        villageName: '',
        sfaqjd: '',
      },
      isSave: true,
      isNewSave: true,
      pageNum: 1,
      showHistoryBtn: false,
      photoData2: []
    }
  },
  methods: {
    HistoryCheck() {
      this.cityList = []
      this.getHistory()
      if (this.$route.query.index == 0) {
        this.saveUpdates(false)
      } else {
        // this.rowDataID = this.$route.query.id
      }
    },
    //上传附件
    afterRead2: async function (file) {
      let _this = this;
      var formData = new FormData();
      formData.append("files", file.file);
      formData.append('path', 'wg')
      formData.append("groupName", this.groupName);
      formData.append("toGroupGuid", this.groupGuid);
      this.JBXXform.houseGroupId = this.groupGuid
      const res = await ossUploadFiles(formData)
      if (res.data.data) {

        // this.photoData2.push({
        //   name:res.data.data[0].name,
        //   id:res.data.data[0].id
        // })
        this.$toast.success('上传成功!')
      }
    },
    //删除附件
    delectFile2: async function (file) {
      // let arr = [];
      // arr.push(file.id)
      // const res = await ossdelteFiles(arr)
      // this.$toast.success(res.data.msg)
      let arr = [];
      arr.push(file.id)
      // this.photoData2.forEach((item,index)=>{
      //   if (item.name==file.file.name) {
      //     arr.push(item.id)
      //   }
      // })
      // this.JBXXform.houseGroupId.forEach((item,index)=>{
      //   if (item==arr[0]) {
      //     this.JBXXform.houseGroupId.splice(index,1)
      //   }
      // })
      const res = await ossdelteFiles(arr)
      this.$toast.success(res.data.msg)
    },
    //打开附件
    handlePictureCardPreview(file) {
      var url = window.g.BaseURL + 'api/upload/oss/preview?fileId=' + file.id;
      this.$router.push({
        path: '/PDFJSViewer',
        query: {
          path: url,
        },
      })
      //Eca.Window.OpenWebUrl('预览', file.url, ["85vw", "90vh"]);
    },
    //附件
    getGroupGuids(item, list) {
      this.groupName = item.name;
      this.groupGuid = item.groupGuid;
    },
    //鉴定机构名称选中
    onConfirmJDDJ(val) {
      this.JBXXform.usccName = val.qymc;
      this.JBXXform.uscc = val.zzjgdm;
      this.Enum.ISJDDJ = false;
    },
    onConfirmJDJG(val) {
      this.JBXXform.appraiseFirst = val.value;
      this.Enum.ISJDJG = false
      this.JBXXform.uscc = ""
      this.JBXXform.usccName = ""
    },
    goback(){
      if (JSON.parse(this.$route.query.data).id) {
        this.rowDataID = JSON.parse(this.$route.query.data).id
      }
      // if (this.rowDataID) {
        this.rowData.id = this.rowDataID
        // this.rowData = this.recordRowData
        this.getData()
      // }

      this.showHistory = false
      this.showHistoryBtn = false

    },
    async onLoad() {
      this.pageNum += 1
      this.getHistory()
    },
    SelectGoto: async function (data) {
      this.showHistoryBtn = true
      this.rowData = data
      if (data) {
        this.ISShow = false
        this.rowData = data
        this.getData()
        if (this.rowData.isTrusted) {
          this.ISShow = true
        }
      } else {
        this.ISShow = true
      }
      this.showHistory = false
      // let parmes = {
      //   cityCode: data.cityCode,
      //   houseUse: 6,
      //   masterName: '',
      //   pageNo: 0,
      //   pageSize: 0,
      //   roleType: window.sessionStorage.getItem('citycodeRole'),
      // }
      // if (data.cityCode.length < 12 ||(data.cityCode.length  == 12 && data.cityCode.endsWith('000'))) {
      //   if (
      //     window.sessionStorage.getItem('citycodeRole') == '0' &&
      //     window.sessionStorage.getItem('SelectCity') == '1'
      //   ) {
      //     parmes.roleType = 1
      //   } else if (
      //     window.sessionStorage.getItem('citycodeRole') == '0' &&
      //     window.sessionStorage.getItem('SelectCity') == '2'
      //   ) {
      //     parmes.roleType = 2
      //   } else if (
      //     window.sessionStorage.getItem('citycodeRole') == '1' &&
      //     window.sessionStorage.getItem('SelectCity') == '2'
      //   ) {
      //     parmes.roleType = 2
      //   }
      //   const res = await houseCheckSupervisionFwCheckList1(parmes)
      //   this.cityName = res.data.data
      //   console.log(data,'xiaohe')
      //   console.log(window.sessionStorage.getItem('citycodeQXName'), 'kkkk')
      //   this.XZQHName = this.XZQHName + '  ' + data.cityName
      // } else {
      //   //选中了村 前去填表单
      //   this.ISshow = false
      //   this.XZQHName = this.XZQHName + '  ' + data.cityName
      //   window.sessionStorage.setItem('citycodeQXName1', this.XZQHName)
      //   window.sessionStorage.setItem('citycodeCun', data.cityCode)
      //   this.$router.push({
      //     path: '/SinceBuilding',
      //     query: {
      //       data: data.cityCode,
      //     },
      //   })
      // }
    },
    getHistory: async function () {
      this.loading = true
      let data = JSON.parse(this.$route.query.data)
      let param = {
        "yhfwbh": data.yhfwbh,
        "cityCode": data.cityCode,  // 当前行的queryCityCode，必传
        // "taskId": JSON.parse(JSON.parse(this.$route.query.data2)).id,  // 必传
        // "taskStatus": 1,  // 检查状态，必传
        "pageNum": this.pageNum,
        "pageSize": 10,

      }
      let result = await axios.post(`${this.BaseURL}/api/farmerHouse/houseCheckFwCheckCountry/checkList`, param);
      if (result.data && result.data.data.pageList.length) {
        // this.loading = false;
        // this.cityList = result.data.data.pageList

        this.loading = false;
        result.data.data.pageList.forEach((item, index) => {
          this.cityList.push(item)
        })
        if (this.cityList.length == result.data.data.totalCount) {
          this.finished = true;
        }
      } else {
        this.cityList = []
        this.loading = false;
        this.finished = true;
      }
      // if (result.data.data.pageList.length>0) {
      //   this.cityList = result.data.data.pageList
      //   this.finished = true
      //   this.loading = false
      // } else {
      //   this.cityList = []
      //   this.finished = true
      //   this.loading = false
      // }
      this.showHistory = true
    },
    //图片回显
    async getPhoto(data1,type) {
      if (type=='现场照片') {
        this.contentData[17].fileData[0].fileList = []
        data1.forEach((item, index) => {
          this.contentData[17].fileData[0].fileList.push({
            url: window.g.BaseURL + "api/upload/oss/preview?fileId=" + item,
            isImage: true,
          })
        })
      } else  {
        this.fileList[0].fileList = []
        data1.forEach((item, index) => {
          this.fileList[0].fileList.push({
            url: window.g.BaseURL + "api/upload/oss/preview?fileId=" + item,
            isImage: true,
          })
        })
      }

    },
    mutualClick(item, item1) {
      let newArr = []
      //判断是不是所有的多选都是无异常如果是this.houseCheckInfo.checkFirstResult = 1 如果不是this.houseCheckInfo.checkFirstResult = 2
      if (item.value == '1') {
        this.houseCheckInfo[item1.key] = ['1']
      } else {
        if (this.houseCheckInfo[item1.key].length > 1) {
          this.houseCheckInfo[item1.key].forEach((item) => {
            if (item != '1') {
              newArr.push(item)
            }
          })
          this.houseCheckInfo[item1.key] = newArr
        }
      }
      for (let a in this.houseCheckInfo) {
        for (let b in this.CheckS) {
          if (a == b) {
            this.CheckS[b] = this.houseCheckInfo[a]
          }
        }
      }
      // for (let c in this.CheckS) {
      //   if (this.CheckS[c].join() != '1') {
      //     this.houseCheckInfo.checkFirstResult = 2
      //     break
      //   } else {
      //     this.houseCheckInfo.checkFirstResult = 1
      //   }
      // }
      // console.log(this.houseCheckInfo.checkFirstResult)
    },
    NumberCheck: async function () {
      let params = {
        accessCode: 'a02f84a3615d11ec87416805cab640a0',
        cityCode: window.sessionStorage.getItem('citycodeCun'),
        appKey: '6738b790-69e8-11ec-a673-6805cab640a0',
        params: { entname: this.formData.cqdwmc },
      }
      const res1 = await getPoliceData(params)
      if (res1.data.code == '200' && res1.data.data.datas && JSON.parse(res1.data.data.datas).length > 0) {
        this.isyezz = true
        this.formData.cqdwxydm = JSON.parse(res1.data.data.datas)[0].ELC_LICENCE_STRUCT.DATA.UNISCID
        this.formData.cqdwfr = JSON.parse(res1.data.data.datas)[0].ELC_LICENCE_STRUCT.DATA.NAME
      } else {
        this.isyezz = false
      }
      if (this.isyezz) {
        this.$toast.success('核验成功!')
      } else {
        Dialog.alert({
          title: '提示',
          message: '经与工商局大数据信息核对，您录入的企业信息不存在，请核实。',
        }).then(() => {
          // on close
        })
        // this.$toast.fail("经与工商局大数据信息核对，您录入的企业信息不存在，请核实。");
      }
    },
    onclickplice: async function () {
      var p = {
        appKey: '6738b790-69e8-11ec-a673-6805cab640a0',
        accessCode: '4f54f932615d11ec87416805cab640a0',
        cityCode: window.sessionStorage.getItem('citycodeCun'),
        params: { czrkgmsfhm: this.formData.cqrzjhm },
      }
      var resData = await getPoliceData(p)
      if (resData.data.data && resData.data.data.datas && resData.data.data.datas.length > 0) {
        resData.data.data.datas.forEach((item) => {
          if (
            item.ELC_LICENCE_STRUCT.DATA.CZRKGMSFHM == this.formData.cqrzjhm &&
            item.ELC_LICENCE_STRUCT.DATA.CZRKHZXM == this.formData.cqrxm &&
            item.ELC_LICENCE_STRUCT.DATA.CZRKYHZGX == '户主'
          ) {
            this.ishz = true
          }
        })
      } else {
        this.ishz = false
      }
      this.$nextTick(() => {
        if (this.ishz) {
          this.$toast.success('核验成功!')
        } else {
          Dialog.alert({
            title: '提示',
            message: '经与公安厅户籍大数据信息核对，您录入的人员信息不存在，请核实。',
          }).then(() => { })
          // this.$toast.fail("");
        }
      })
    },
    editData() {
      if (this.rowData) {
        this.isAdd = true
      } else {
      }
    },
    //回显
    getData: async function () {
      let param = {
        // "cityCode": "330200000000",
        // "fwid": "1688397962322449244"
        "cityCode": this.rowData.cityCode,
        "fwid": this.rowData.fwid,
        "id": this.rowData.id
      }
      const res = await houseCheckFwCheckCountryGet(param)
      let data1 = res.data.data
      if (data1) {
        //有数据表示是回显
        if (data1.houseCheckInfo) {
          this.isNewSave = false
        } else {
          this.isNewSave = true
        }

        if (data1.houseCheckInfo != null) {
          let houseGroupFileList = data1.houseCheckInfo.houseGroupFileList
          if (houseGroupFileList!==null && houseGroupFileList.length>0) {
            this.fileList[0].fileList = []
            houseGroupFileList.forEach((item,index)=>{
              if (window.g.IsEnabled == "1"){
                this.fileList[0].fileList.push({
                  id: item.id,
                  url: window.g.OSSPriview + item.fileUrl,
                  isImage: true,
                  name: item.fileName,
                })
              } else {
                this.fileList[0].fileList.push({
                  id: item.id,
                  url: window.g.BaseURL + 'api/upload/oss/preview?fileId=' + item.id,
                  isImage: true,
                  name: item.fileName,
                })
              }
            })
          } else {
            this.fileList[0].fileList = []
          }
          //需要将字符串变成数组
          let data = {
            buildEnums: [],
            baseEnums: [],
            liveBrickEnums: [],
            liveWoodEnums: [],
            liveBetonEnums: [],
            houseEnums: [],
            useSafeEnums: [],
          }
          for (let item in data1.houseCheckInfo) {
            for (let it in data) {
              if (item == it) {
                data1.houseCheckInfo[item] = data1.houseCheckInfo[item].split(',')
              }
            }
            if ( data1.houseCheckInfo[item]!== null && item!=='houseGroupFileList') {
              this.houseCheckInfo[item] = data1.houseCheckInfo[item]
            }
          }
          if (this.houseCheckInfo.pictures=="") {
            this.houseCheckInfo.pictures = []
            this.contentData[17].fileData[0].fileList = []
          }else {
            this.houseCheckInfo.pictures = this.houseCheckInfo.pictures.split(",")
          }
          this.houseCheckInfo.taskId = this.$route.query.id
          if (this.houseCheckInfo.pictures.length > 0) {
            this.getPhoto(this.houseCheckInfo.pictures, "现场照片")
          }
          for (let i in this.JBXXform) {
            this.JBXXform[i] = data1.houseCheckInfo[i]
          }
          // if (!!this.JBXXform.houseGroupId) {
          //   this.JBXXform.houseGroupId = this.JBXXform.houseGroupId.split(",")
          // }else {
          //   this.JBXXform.houseGroupId = []
          // }
          // if(this.JBXXform.houseGroupId.length>0){
          //   this.getPhoto(this.JBXXform.houseGroupId,"房屋照片")
          // }
        } else {
          this.houseCheckInfo = {}
          this.getPhoto([],"现场照片")
          this.getPhoto([],"房屋照片")
          this.houseCheckInfo = {
            baseEnums: [],
              buildEnums: [],
              checkFirstResult: 0,
              checkTime: '',
              checkUser: '',
              fwid: '',
              fwlx: 0,
              houseEnums: [],
              isCheck: 0,
              jcCheckInfo: 0,
              jcCheckInfoInput: '',
              jcHouseUse: 0,
              // jcIsFirstRestut: 0,
              jcIsJd: 0,
              jcIsJdbg: 0,
              // jcIsZpxc: 0,
              jcJdjgFhyq: 0,
              jcOther: '',
              // jcTyshxydm: '',
              jcWfgc: 0,
              jcWfgk: 0,
              liveBetonEnums: [],
              liveBrickEnums: [],
              liveWoodEnums: [],
              pictures: [],
              useSafeEnums: [],
          }
          this.houseCheckInfo.taskId = this.$route.query.id
          this.houseCheckInfo.fwid = this.rowData.fwid
          this.houseCheckInfo.cityCode = this.rowData.cityCode
          this.houseCheckInfo.checkTime = this.getDate()
          this.houseCheckInfo.checkUser = JSON.parse(window.localStorage.getItem('userName')).userName
          this.JBXXform = {
            appraiseFirst: 0,
              removeDangerMode:"",
              usccName: "",
              uscc: "",
              houseGroupId:"",
              checkUserId:''
          }
        }
        if (data1.zjfInfo != null) {
          this.formData = data1.zjfInfo
          this.formData.renovateFlag = this.formData.renovateFlag == 1 ? '是' : '否'
        } else {
          this.formData = {
            cityByCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
            cityByName: '杭州市',
            citycode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
            countryCode: '',
            countryName: '',
            cqrxm: '',
            cqrzjhm: '',
            fwid: '',
            fwpcqk: '',
            fwtybh: '',
            fwyt: 0,
            gkjlx: '',
            gkjnr: '',
            isDelete: 0,
            jcFwJl: '',
            jcJglxJl: '',
            jglx: 0,
            jtjglx: '',
            jtjglxnr: '',
            provinceCode: '330000000000',
            provinceName: '惠州市',
            sfgkj: 0,
            sftszz: 0,
            sjlx: 0,
            townCode: '',
            townName: '',
            villageCode: '',
            villageName: '',
            sfaqjd: '',
          }
          this.formData.PCSJ = this.getDate(true)
          this.formData.PCR = JSON.parse(window.localStorage.getItem('userName')).userName
        }

      } else {
        //没数据表示新增
        this.isNewSave = true
      }
    },
    async handleYanZheng() {
      this.isTrue1 = false
      let params = {
        accessCode: 'a02f84a3615d11ec87416805cab640a0',
        cityCode: window.sessionStorage.getItem('citycodeCun'),
        appKey: '6738b790-69e8-11ec-a673-6805cab640a0',
        params: { entname: '', uniscid: this.houseCheckInfo.jcTyshxydm },
      }
      const res = await getPoliceData(params)
      if (res.data.data.datas != null) {
        this.isTrue = true
        this.$toast.success('验证成功')
      } else {
        this.$toast.fail('验证失败')
        this.isTrue = false
      }
    },
    handleYanZheng1() {
      this.isTrue1 = true
      this.isTrue = false
    },
    saveUpdates: async function (data) {
      this.houseCheckInfo.isCheck = 0
      let parameter = {}
      for (let key in this.JBXXform) {
        this.houseCheckInfo[key] = this.JBXXform[key]
      }
      for (let key in this.houseCheckInfo) {
        parameter[key] = this.houseCheckInfo[key]
      }
      if (this.houseCheckInfo.checkFirstResult == 2) {
        for (let key in this.JBXXform) {
          if (this.JBXXform[key] !== "") {
            parameter[key] = this.JBXXform[key]
          }
        }
      }
      for (let key in parameter) {
        if (isArray(parameter[key])) {
          parameter[key] = parameter[key].join(',')
        }
      }
      const res = await houseCheckFwCheckCountrySave(parameter)
      let datas = res.data.code
      if (datas == '200') {
        // if (this.isNewSave) {
        this.rowDataID = res.data.data
        // }

        if (data) {
          this.$toast.success(this.isNewSave ? '保存成功!' : '修改成功!')
        }
      }
    },
    //提交
    submitData: async function () {
      debugger
      let add = true
      this.houseCheckInfo.isCheck = '1'
      if (this.houseCheckInfo.checkFirstResult == 2) {
        for (let i in this.JBXXform) {
          this.houseCheckInfo[i] = this.JBXXform[i]
        }
      }
      for (let i in this.houseCheckInfo) {
        if (this.houseCheckInfo.checkFirstResult == 2) {
          if (this.houseCheckInfo.appraiseFirst == 0) {
            if (!this.houseCheckInfo.usccName || !this.houseCheckInfo.uscc || !this.houseCheckInfo.removeDangerMode) {
              add = false
              // alert(1)
              this.$toast.fail('请填写必填项')
              return
            }
          } else {
            if (!this.houseCheckInfo.removeDangerMode) {
              add = false
              // alert(2)
              this.$toast.fail('请填写必填项')
              return
            }
          }
          if (this.houseCheckInfo[i] == "" && this.houseCheckInfo[i] == 0 && i !== 'pictures' && i !== 'jcCheckInfoInput' && i !== 'appraiseFirst' && i !== "usccName" && i !== "uscc"&&i!="checkUserId") {
            add = false
            // alert(i+'3')
            this.$toast.fail('请填写必填项')
            return
          }
        } else {
          if (this.houseCheckInfo[i]=="" && this.houseCheckInfo[i]==0 && i!=='pictures'&&i!=='jcCheckInfoInput' && i!=='appraiseFirst'&& i!=='houseGroupId' && i!=="usccName" && i!=="uscc" && i!=="removeDangerMode"&&i!="checkUserId") {
            add = false
            // alert(i+'4')
            this.$toast.fail('请填写必填项')
            return
          }
        }
      }
      debugger
      //判断
      if ((this.houseCheckInfo.checkFirstResult == 2 || this.houseCheckInfo.checkFirstResult == 3) && this.rowData.yhfwbh) {
        let p = {
          checkNumberFull: this.rowData.yhfwbh,
          processNodesNotIn:"6,30"
        }
        let resultByqueryList= await  queryList(p);
        if (resultByqueryList.data && resultByqueryList.data.data && resultByqueryList.data.data.pageList.length > 0) {
          if (this.houseCheckInfo.checkFirstResult == 2) {
            Dialog.confirm({
              message: `${this.rowData.yhfwbh}房屋已经流转到危房改造${resultByqueryList.data.data.pageList[0].processNodeName}环节，是否继续提交?`,
            }).then(() => {
              this.submit(add)
            })
          } else {
            this.submit(add)
          }
        } else {
          if (this.houseCheckInfo.checkFirstResult == 3) {
            Dialog.confirm({ message: `${this.rowData.yhfwbh}房屋未查询到正在整治中的记录，是否继续提交?` }).then(() => {
              this.submit(add)
            })
          } else {
            this.submit(add)
          }
        }
      } else {
        this.submit(add)
      }

    },
    async submit(add) {
      if (add) {
        for (let key in this.houseCheckInfo) {
          if (isArray(this.houseCheckInfo[key])) {
            this.houseCheckInfo[key] = this.houseCheckInfo[key].join(',')
          }
        }
        const res = await houseCheckFwCheckCountrySave(this.houseCheckInfo)
        let datas = res.data.code
        if (datas == '200') {
          this.$toast.success('提交成功')
          if (this.$route.query.type == "map") {
            this.$router.push({
              path: '/HouseExamination',
              query: {
                citycode: this.rowData.cityCode,
                cityname: "",
              },
            })
          } else {
            this.$router.push({
              path: '/homeInspectionlist',
              query: {
                data: JSON.parse(this.$route.query.data2),
                cityCode: this.$route.query.cityCode
              },
            })
            // this.$router.push({ path: '/CityList' })
          }
        }
      }
    },
    getList(item) {
      this.groupGuids = item.groupGuid
    },
    getFileServerUpload: async function (file, data) {
      let formData = new FormData()
      formData.append('files', file)
      formData.append('path', 'gj')
      formData.append('groupName', '工匠信息')
      formData.append('toGroupGuid', '123')
      const res = await ossUploadFiles(formData)
      let data2 = res.data.data
      this.photoData.push({
        name: data2[0].name,
        id: data2[0].id
      })
      this.houseCheckInfo.pictures.push(data2[0].id)
      // this.formData.fileid = data2[0].id
      this.$toast.success('上传成功!')
    },
    getFile: async function (data) {
      this.UploadFileId = []
      this.contentData[18].fileData[0].fileList = []
      this.fileData = res.data.data
      if (res.data.data) {
        res.data.data.forEach((item, index) => {
          // this.fileIdData.push(item.fileId)
          debugger
          this.UploadFileId.push(item.fileId)
          this.contentData[18].fileData[0].fileList.push({
            url: window.g.BaseURL4 + item.path + '?download=0',
            isImage: true,
            fileId: item.fileId,
          })
        })
      }
    },
    afterRead(file) {
      this.getFileServerUpload(file.file, 'scsfz')
    },
    // getFileServerUpload: async function (file, data) {
    //   let formData = new FormData()
    //   formData.append('file', file)
    //   const res = await dataqueryFile(formData)
    //   let data2 = res.data.data
    //   this.houseCheckInfo.pictures.push(data2.id)
    //   this.$toast.success('上传成功!')
    // },
    delectFile: async function (file) {
      let arr = [];
      this.photoData.forEach((item, index) => {
        if (item.name == file.file.name) {
          arr.push(item.id)
        }
      })
      this.houseCheckInfo.pictures.forEach((item, index) => {
        if (item == arr[0]) {
          this.houseCheckInfo.pictures.splice(index, 1)
        }
      })
      const res = await ossdelteFiles(arr)
      this.$toast.success(res.data.msg)
      // this.contentData[18].fileData[0].fileList = []
    },
    onConfirmContent(val) {
      this.DICNAME = val.DICID
      this.contentData.forEach((item, index) => {
        item.children.forEach((item1, index1) => {
          if (item1.active) {
            this.houseCheckInfo[item1.key] = val.DICID
            item1.active = false
          }
          // if (item1.type=='Checkbox'){
          //   item1.disabled = true
          //   this.$forceUpdate()
          // }
          if (item1.name === '建筑结构') {
            // if (this.houseCheckInfo.live_structer_type){
            //   this.disabled = false
            // }
            this.JZJG.forEach((item2, index2) => {
              if (item2.name === val.DICNAME) {
                item.children.splice(1, item.children.length - 1)
                item2.children.forEach((item3) => {
                  item.children.push(item3)
                })
              }
            })
          }
        })
      })
    },
    onConfirmRQ(val) {
      let year = val.getFullYear()
      let month = val.getMonth() + 1
      let day = val.getDate()
      let hour = val.getHours()
      let minute = val.getMinutes()
      let second = val.getSeconds()
      if (month >= 1 && month <= 9) {
        month = `0${month}`
      }
      if (day >= 1 && day <= 9) {
        day = `0${day}`
      }
      if (hour >= 0 && hour <= 9) {
        hour = `0${hour}`
      }
      if (minute >= 0 && minute <= 9) {
        minute = `0${minute}`
      }
      if (second >= 0 && second <= 9) {
        second = `0${second}`
      }
      this.formData.JCSJ = `${year}-${month}-${day}`
      this.selectData.showPickerq = false
    },
    onConfirm(val) {
      this.selectData.showPicker = false
    },
    onConfirmFWLX(val) {
      this.selectData.showPickerFWLX = false
      this.formData.housetype = val.DICID
    },
    onConfirmJGLX(val) {
      this.selectData.showPickerJGLX = false
      this.formData.jglx = val.DICID
    },
    onConfirmJTJG(val) {
      this.selectData.showPickerJTJG = false
      this.formData.jtjglx = val.DICID
    },
    tabClick(index) {
      this.nowIndex = index
    },
    onConfirmFWYT(val) {
      this.selectData.showPickerFWYT = false

      this.formData.fwyt = val.DICID
    },
    onConfirmFWYT1(val) {
      this.selectData.showPickerFWYT1 = false
      this.formData.sftszz = val.DICID
    },
    onConfirmIFTSZZ(val) {
      this.selectData.showPickerIFTSZZ = false
      this.formData.JZCS = val.DICID
    },
    onConfirmGKJ(val) {
      this.selectData.showPickerGKJ = false
      this.formData.sfgkj = val.DICID
    },
    onConfirmsfgkj(val) {
      this.selectData.showPickersfgkj = false
      this.formData.sfgkj = val.DICID
    },
    onConfirmjdjl(val) {
      this.selectData.showPickerjdjl = false
      this.formData.jdjl = val.DICID
    },
    onConfirmsfaqjd(val) {
      this.selectData.showPickersfaqjd = false
      this.formData.sfaqjd = val.DICID
    },
    onConfirmaqyhcp(val) {
      this.selectData.showPickeraqyhcp = false
      this.formData.aqyhcp = val.DICID
    },
    deleteData: async function () {
      if (this.rowData || this.isSave) {
        const res1 = await FwsaveOrDeleteFwCheck(this.houseCheckInfo.fwid)
        if (res1.data.data) {
          this.$toast.success('删除成功!')
        }
      } else {
        // this.$toast.fail
      }
    },
    getEnum: async function (viewID) {
      // b65d1943-66f4-49b1-b759-cd9f079dc0d3
      let params = {
        accessCode: '688bd3883572440a859dfd8ba9194e7b',
        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
        params: {
          dataguid: viewID,
          searchObject: JSON.stringify([]),
          token: window.localStorage.getItem('token'),
        },
      }
      const res = await FileServerProxy(params)
      switch (viewID) {
        case 'b65d1943-66f4-49b1-b759-cd9f079dc0d3':
          this.selectData.columnsJGLX = JSON.parse(res.data.data).Data
          break
        default:
          break
      }
    },
    //查询鉴定机构下拉内容
    getAccrediting: async function () {
      let parm = {
        "belongCountryList": [],
        "belongCountyList": [],
        "name": "",
        "pageNo": 1,
        "fwlx": "鉴定机构",
        "pageSize": 100000
      }
      let webResult = await axios.post(this.BaseURL + '/api/farmerHouse/zhejiangHouseTechnicalUnit/selectTechnicalList', parm, {
        headers: {
          isOutParam: true,
        },
      });
      this.Enum.JDDJ = webResult.data.data.pageList
    },
  },
  mounted() {
    this.fileList[0].groupGuid = this.newGuid()
    this.getAccrediting()
    this.formData.PCSJ = this.getDate(true)
    this.formData.PCR = JSON.parse(window.localStorage.getItem('userName')).userName
    // this.getEnum('b65d1943-66f4-49b1-b759-cd9f079dc0d3')
    // this.cityName = window.sessionStorage.getItem('citycodeQXName1D').split('  ')
    if (this.$route.query.data) {
      this.ISShow = false
      this.rowData = JSON.parse(this.$route.query.data)
      this.JBXXform.checkUserId = this.rowData.checkUserId
      this.recordRowData = JSON.parse(this.$route.query.data)
      this.houseCheckInfo.taskId = this.$route.query.id
      this.houseCheckInfo.fwid = this.rowData.fwid
      this.houseCheckInfo.cityCode = this.rowData.cityCode
      this.houseCheckInfo.checkTime = this.getDate()
      this.houseCheckInfo.checkUser = JSON.parse(window.localStorage.getItem('userName')).userName
      this.getData()
      if (this.rowData.isTrusted) {
        this.ISShow = true
      }
    } else {
      this.ISShow = true
    }
    dd.ready(function () {
      dd.setTitle({
        title: '房屋检查'
      })
        .then((res) => { })
        .catch((err) => {
          console.error(err)
        })
    })
  },
}
</script>

<style scoped lang="scss">
#SinceBuildings {
  /*font-size: 14px;*/
  height: 100vh;
  overflow-y: hidden;
  padding: 10px 0;

  .middle {
    /*padding: 10px;*/
    background: #ffffff;

    .search-list {
      height: 94vh;
      .search-list-top {
        overflow: auto;
        background-color: #fff;
        /*border-radius: 8px;*/
        padding: 15px;
        border-bottom: 1px solid #ebedf0;
        // box-shadow: 0 3px 3px rgba(0, 0, 0, 0.2);
        /*margin-bottom: 8px;*/

        .top {
          display: flex;
          justify-content: space-between;
          line-height: 24px;
          color: #aaa;
        }

        .top1 {
          display: flex;
          justify-content: space-between;
          line-height: 24px;
          clear: both;
          color: #aaa;
        }

        .bottom {
          display: flex;
          justify-content: space-between;
          line-height: 20px;
        }
      }
    }
  }

  .list ul li {
    min-height: 50px;
    line-height: 50px;
    padding: 0 10px;
  }

  .btn-style1 {
    width: 67px;
    height: 30px;
    background: #eff6ff;
    border-radius: 4px;
    float: right;
    margin-top: -38px;
    display: inline-block;
    text-align: center;
    line-height: 30px;
    font-size: 14px;
    color: #007aff;
  }

  .tab ul li {
    width: 49%;
    height: 50px;
    background: #fff;
    float: left;
    /*line-height: 50px;*/
    text-align: center;
    color: #000;
    padding-top: 10px;
  }

  .content {
    width: 100%;
    height: calc(100vh - 120px);
    overflow-y: auto;
    padding: 10px;
  }

  .footer {
    width: 100%;
    padding: 20px;
    text-align: center;
    /*display: flex;*/
    /*justify-content: space-between;*/
  }

  .select {
    color: #007aff !important;
  }

  .top {
    font-size: 14px;
  }

  .top1 {
    font-size: 18px;
  }
}
</style>
